// pages/address/address.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.load();
  },
  async load(){
    let res=await wx.util.post("user/profile",{},false);
    this.selectComponent("#liuChooseAddress").setTel(res.data.utel)
  },
   //添加地址成功回调
   async submitAddress(e) {
    let data = e.detail;
    //拿到地址信息、表单数据、是否默认地址等
    console.log('添加调地址信息：', data)

    if(data.address==""){
      wx.util.toast('请选择上门地址');return;
    }
    if(data.detailAddress==""){
      wx.util.toast('请填写门牌号详细地址');return;
    }
    if(data.userName==""){
      wx.util.toast('请填写联系人');return;
    }
    if(data.userPhone==""){
      wx.util.toast('请填写联系人手机号');return;
    }
    await wx.util.post("address/add",data);
    wx.navigateBack({
      delta: 1
    });
  },
  //删除地址回调
  deteleAddress() {
    // 逻辑自行添加
  },
  //地址回显调用此方法
  editAddress() {
    let obj = {
      detailAddress: '',
      userName: '',
      userPhone: '',
      lableName: '',
      sexType: '',
      title: '',
      address: '',
      address2: {},
      latitude: '',
      longitude: '',
      agreeState: ''
    }
    this.selectComponent("#liuChooseAddress").setDataInfo(obj)
  }
})